<template>
  <div>
    <form @submit.prevent="fn">
      <label>姓名：</label>
      <input type="text" v-model="uname" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model="age" /><br /><br />

      <label>身高：</label>
      <input type="text" v-model="stature" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model="weight" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="disease" /><br /><br />

      <button>诊断</button>
    </form>

    <p v-show="flag">患者 {{ uname }} 的诊断结果:{{ getsum }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      uname: '',
      age: '',
      stature: '',
      weight: '',
      disease: '',
      getsum: '',
      flag : false
    }
  },
  methods: {
    fn() {
      this.getsum = this.weight / (this.stature ^ 2)
      if (this.getsum < 18) {
        this.getsum = '你有点过轻了，多吃哦！'
      } else if (this.getsum >= 18 && this.getsum < 25) {
        this.getsum = '你的体重刚刚好，注意保养！'
      } else if (this.getsum >= 25 && this.getsum < 28) {
        this.getsum = '你的体重有点超标哦，注意饮食清淡哦！'
      } else if (this.getsum >= 28 && this.getsum < 32) {
        this.getsum = '你的体重已经是肥胖了，规划规划减肥吧！'
      } else {
        this.getsum = '你的体重严重肥胖啦，不减肥不行啦！'
      }
    this.flag = true
    },
  },
}
</script>
